<h1>Getting Started with AllForGood: modifying the core code</h1>

<h3>Downloading and running a local server</h3>
<ol>
<li>(10mins) install Google App Engine (<a href="http://code.google.com/appengine/docs/python/gettingstarted/devenvironment.html">instructions</a>).<br />requires Python; most operating systems supported.</li>

<li>[if needed] (1 hour) install a Subversion client.  Subversion is pre-installed on most unix/linux systems.  If this proves difficult, or you don't have time, email one of the core team and we'll provide you a zip/tarball.</li>

<li>Check out a copy of the source code (<a href="http://code.google.com/p/footprint2009dev/source/checkout">instructions</a>).  To check out the repository in read-only mode:<br />
<pre>
   svn checkout http://footprint2009dev.googlecode.com/svn/trunk/
   footprint2009dev-read-only
</pre>
To check out the repository with write permissions (you will need to be a member of the project for code hosting):
<pre>
   svn checkout https://footprint2009dev.googlecode.com/svn/trunk/
   footprint2009dev --username gmail.user</pre>

When prompted for password, use the one automatically generated for your Gmail account (to which you'll need to be logged in) <a href="http://code.google.com/hosting/settings">here</a>.</li>

<li>create a frontend/private_keys.py file and fill it with your private keys:<br />
<pre>
       DEFAULT_FACEBOOK_SECRET = '62354267436743487347364873473'
       # Secret keys unique to our domains
       FACEBOOK_SECRETS = {
         'yourdomain.com': '7q64373264736487364873642873648734',
       }
</pre></li>
<li>To start appengine locally, from the root of the Footprint repository checkout issue:<br />
<pre>
../google_appengine/dev_appserver.py frontend/
</pre></li>

<li>Load the app in a browser with this address: <a href="http://localhost:8080/">http://localhost:8080/</a><br /><br />

Tip: If this fails, you may need to add "-a &lt;ip address&gt;" to the dev_appserver.py command above.</li>
</ol>

<h3>Tech support</h3>
Please join this group to get tech support: <a href="http://groups.google.com/group/footprint-eng">http://groups.google.com/group/footprint-eng</a>

<h3>HTML/CSS/JS and Django Templates</h3>

The site is an 'AJAX' app coded in HTML/CSS/JS.  The directories are frontend/css, frontend/html, frontend/js and frontend/images.  The code is fairly self-explanatory, with these notes:
<ul>
<li>login_bar.html -- this is loaded asynchronously, to avoid blocking search results from loading before user login is checked.</li>
<li>/ui_snippets -- this is the actual search call, and should be executed ASAP, in parallel with the rest of the page loading.</li>
</ul>

The frontend template files use <a href="http://docs.djangoproject.com/en/dev/topics/templates/#template-inheritance">Django inheritance</a> to simplify assembly. The base template file is "base.html", and it defines a number of blocks which can be overridden. One of these blocks is named content_layout, and it occupies the main area of the page, below the header and above the footer.content_layout is overridden inside a layout file (for example, "layout_full.html"). The layout file then defines one of more content blocks, which are overridden by a specific frontend page.<br /><br />

There are two layout files checked in: 
<ul>
<li>layout_full.html - exposes a single content block that takes up entire region between header and footer.</li>
<li>layout_two_column.html - exposes two content blocks: content_left and content_right. By default the left block takes up 50% of the window. This can be overridden using width_left and width_right</li>
</ul>

The search results template (templates/search_results.html) uses the two column layout, while the post template (templates/post.html) uses the "full" layout.<br /><br />

The following blocks are exposed by base.html, and can be overridden in any derived template page:
<ul>
<li>css_files: &lt;link&gt; tags for css files to include.</li>
<li>js_files: &lt;script&gt; tags for JS files to include.</li>
<li>subheader: area below header.</li>
<li>prefooter: area above footer.</li>
<li>content_layout: the main area inside the body, below the header, or below the subheader if defined.  This should only be overridden by layout templates.</li>
</ul>


<h3>Coding Style</h3>

We use pylint as our standard for automatically checking style adherance, and have a custom <a href="http://code.google.com/p/footprint2009dev/source/browse/trunk/pylintrc">pylintrc</a> for the project checked into the toplevel directory.  To run pylint and automatically pickup our rc file:
<pre>
      cd footprint2009dev; pylint path/to/filename.py
</pre>
The output is parseable e.g. for use in emacs compile-mode.<br /><br />

At this time, we are NOT aiming for 100% compliance-- a score above  &gt;=9.0 per file is good enough, but please try to adhere to function/variable naming, indentation and line lengths (to ease code review).<br />

<h3>Code Review and Checking in Changes</h3>

core team: paul.rademacher@gmail.com, adam.sah@gmail.com, doll.cassie@gmail.com.
<ol>
<li>For one-time and occasional developers, email footprint-eng@googlegroups.com with a brief description of the changes and a patch file.</li>

<li>for ongoing contributors, first get write access to the repository from one of the core members, then get a code review: /path/to/footprint2009dev/codereview_upload.py %lt;email of primary reviewer%gt;</li>
</ol>

<h3>Deployment to an AppEngine server</h3>

You can (and should) deploy your code to your own appengine instance first.  Instructions for uploading application are <a href="http://code.google.com/appengine/docs/python/tools/uploadinganapp.html">here</a>.<br /><br />

The team's shared development AppEngine instance is named "footprint2009dev".  To get deployment access, contact one of the core engineers, above.  Please only upload code reviewed, SVN-committed versions of the source code, without any local changes, and upload immediately to avoid conflicts with other developers.<br /><br />

To update the dev environment with changes you've committed to SVN, issue this command from the root of the Footprint repository:
<pre>
../google_appengine/appcfg.py update frontend/
</pre>

Important: Your Gmail account must be listed as a Project Member for appengine, and not just for code hosting, to update environments. If this listing changed recently, you will need to accept the invitation (sent to your Gmail account, of course) before proceeding.<br /><br />

When prompted for email, include your full Gmail address: your.name@gmail.com<br /><br />

When prompted for password, include your Gmail password (not the one provided at code.google.com).<br /><br />


<h3>Engineering Glossary: </h3>
Since AFG started with google engineers, we've adopted google engineering lingo:
<ul>
<li><b>Footprint</b>-- the codename for AllForGood (aka "AFG").  We're slowly scrubbing the
     code and docs, but it'll take a long time, and it's not a priority.</li>
<li><b>CL</b>-- "change list" aka proposed or already-committed set of code changes.</li>
<li><b>code review</b>-- as per google engineering, virtually all submissions are proposed
     before being committed to the source repository.  This is done by having the code
     read carefully by a person with domain experience with the algorithms, as well as
     a person (potentially a 2nd reviewer) with experience in the affected code.</li>
<li><b>design doc/review</b>-- as per google engineering, substantial projects require the
     engineer to publish a paper design, including explanations of the key requirements
     (technical and product) and how this design meets those requirements, competing
     solutions and they were rejected, and infrastructure & algorithm choices.</li>
<li><b>P0/P1/P2 bugs</b>-- P0 are blocking, stop-everything-and-fix-it bugs and with no known
     workaround.  P1 are blocking bugs affecting a subset of users, with no known
     workaround.  P2 bugs have workarounds, however hacky/awful.  P3 and below
     are minor annoyances, to be fixed if it's easy, or as part of "fixit" efforts.</li>
<li><b>issue</b>-- synonym for bug.</li>
<li><b>codesite</b>-- synonym for project hosting on code.google.com, i.e. code.google.com/p</li>
<li><b>lg/lgtm/sgtm</b>-- "looks/sounds good to me".  LGTM is particularly important, because
     it is often mentioned in searches, i.e. important to standardize on LGTM for code
     reviews and other processes.  </li>
<li><b>Code Red/Yellow/Green</b>-- codes are used by ops teams to indicate severity+urgency
     levels for live situations.  Code Red is a site outage and takes priority over all other
     projects, and typically comes with hourly reporting.  Code Yellow are ongoing 
     situations (e.g. high latency, long submission queues) for which a subset of the team
     is 100% allocated to addressing them, and given priority over new features.
     Code Green is the base state where sleep is allowed.</li>
<li><b>Fixit</b>-- a structure process (typically one full day) where 100% of engineering works
     on nothing but fixing things under some common theme.  examples include
     docs fixits, bugs fixits, internationalization fixits, performance/latency fixits, etc.
     Fixits are coordinated top-down from PM and engineering management, with a
     single eng lead for the day.</li>
</ul>